#!/usr/bin/env python3

import sys
import os
import shutil
import json
import platform
from typing import List

script_path = os.path.dirname(sys.argv[0])

class StrFilter:
    def __init__(self, strs: List[str]):
        self.strs = strs


class StdOutFilter(StrFilter):
    def filter(self, jsobj: json):
        for filterStr in self.strs:
            if filterStr not in jsobj["stdout"]:
                return False
        return True


class StdErrFilter(StrFilter):
    def filter(self, jsobj: json):
        for filterStr in self.strs:
            if filterStr not in jsobj["stderr"]:
                return False
        return True

class BlackListFilter:
    def __init__(self, file: str):
        with open(file, 'r', encoding='utf-8') as f:
            self.list = list(line.strip() for line in f)
        # print(f"{file} list size: {len(self.list)}")

    def filter(self, jsobj: json):
        return jsobj["name"] in self.list


class FailCollector:
    def __init__(self, filter, tag: str, desc: str, maximum=0):
        self.filter = filter
        self.tag = tag
        self.desc = desc
        self.failList = []
        self.maximum = maximum

    def run(self, jsobj: json):
        if self.filter == "99_others":
            self.failList.append(jsobj)
            return True
        if self.filter.filter(jsobj):
            self.failList.append(jsobj)
            return True
        else:
            return False


class FailCollector2:
    def __init__(self, filters, tag: str, desc: str, maximum=0):
        self.filters = filters
        self.tag = tag
        self.desc = desc
        self.failList = []
        self.maximum = maximum

    def run(self, jsobj: json):
        for filter in self.filters:
            if filter.filter(jsobj):
                self.failList.append(jsobj)
                return True
        return False

test262_failCollectors_be = [
FailCollector(StdErrFilter(["AOT::precompile_with_js failed"]),                 "01 precompile_with_js_failed", "",                 0    ),
    FailCollector(StdErrFilter(["MaglevGraphBuilder"]),                             "02 MaglevGraphBuilder", "",                        0    ),
    FailCollector(StdErrFilter(["goto_label_->statement()"]),                       "03 goto_label_->statement()", "",                  0    ),
    FailCollector(StdErrFilter(["nameTable_[scope].count"]),                        "04 nameTable_[scope].count", "" ,                  0    ),
    FailCollector(StdErrFilter(["eval not fully support"]),                         "05 eval not fully support", "",                    54   ),
    FailCollector(StdOutFilter(["GenerateBytecode verifyModule fail"]),             "06 GenerateBytecode verifyModule fail", "",        0    ),
    FailCollector(StdErrFilter(["Check failed: IsSmi"]),                            "07 Check failed: IsSmi", "",                       0    ),
    FailCollector(StdOutFilter(["undefined:1: EvalError"]),                         "08 undefined:1: EvalError", "",                    112  ),
    FailCollector(StdOutFilter(["got a EvalError"]),                                "09 got a EvalError", "",                           63   ),
    FailCollector(StdErrFilter(["GenDebuggerStatement"]),                           "10 GenDebuggerStatement", "",                      2    ),
    FailCollector(StdErrFilter(["GenCallRuntime"]),                                 "11 GenCallRuntime:", "",                           980  ),
    FailCollector(StdErrFilter(["GenWithStatement"]),                               "13 GenWithStatement:", "",                         224  ),
    FailCollector(StdErrFilter(["GenGetTemplateObject"]),                           "14 GenGetTemplateObject:", "",                     0    ),
    FailCollector(StdErrFilter(["BuildVariableLoad"]),                              "15 BuildVariableLoad:", "",                        23 if platform.machine() == 'x86_64' else 0),
    FailCollector(StdErrFilter(["Runtime_ResolvePossiblyDirectEval"]),              "17 Runtime_ResolvePossiblyDirectEval:", "",        107  ),
    FailCollector(StdErrFilter(["BuildVariableAssignment"]),                        "18 BuildVariableAssignment:", "",                  54   ),
    FailCollector(StdErrFilter(["PrepareAssignmentLhs"]),                           "18 PrepareAssignmentLhs:", "",                     0    ),
    FailCollector(StdErrFilter(["index < size()"]),                                 "19 index < size():", "",                           0    ),
    FailCollector(StdOutFilter(["HermesBuiltin_throwTypeError"]),                   "20 HermesBuiltin_throwTypeError", "",              0    ),
    FailCollector(StdOutFilter(["slot0"]),                                          "21 block scope: slot0", "",                        0    ),
    FailCollector(StdErrFilter(["!(is_async && is_generator)"]),                    "22 !(is_async && is_generator):", "",              0    ),
    FailCollector(StdOutFilter(["TypeError: Cannot read properties of undefined"]), "23 Cannot read properties of undefined", "",       0    ),
    FailCollector(StdOutFilter(["is not defined"]),                                 "24 reference_error", "",                           745  ),
    FailCollector(StdOutFilter(["Test262:AsyncTestFailure"]),                       "25 Test262:AsyncTestFailure", "",                  571  ),
    FailCollector(StdOutFilter(["should have the same contents"]),                  "26 should have the same contents", "",             0    ),
    FailCollector(StdOutFilter(["Test262Error to be thrown"]),                      "27 Test262Error to be thrown", "",                 16   ),
    FailCollector(StdOutFilter(['Expected SameValue']),                             '28 Expected SameValue', "",                        44   ),
    FailCollector(StdOutFilter(['Expected a TypeError to be thrown']),              '29 Expected a TypeError to be thrown', "",         16   ),
    FailCollector(StdOutFilter(['Expected a SyntaxError']),                         '30 Expected a SyntaxError', "",                    2    ),
    FailCollector(StdOutFilter(['Expected a ReferenceError']),                      '31 Expected a ReferenceError', "",                 0    ),
    FailCollector(StdOutFilter(['descriptor value should be']),                     '32 descriptor value should be', "",                0    ),
    FailCollector(StdOutFilter(["Test262Error: "]),                                 "33 Test262Error:", "",                             12   ),
    FailCollector(StdErrFilter(["syntax check should be performed"]),               "34 regx syntax check should be performed", "",     0    ),
    FailCollector(StdErrFilter(["TIMEOUT"]),                                        "35 TIMEOUT", "",                                   0    ),
    FailCollector(StdOutFilter(["native code"]),                                    "36 native code", "",                               2    ),
    FailCollector(StdErrFilter(["Received signal 11 SEGV_MAPERR"]),                 "37 Received signal 11 SEGV_MAPERR", "",            0    ),
    FailCollector(StdOutFilter(["TypeError: undefined is not a function"]),         "38 TypeError: undefined is not a function", "",    0    ),
    FailCollector(StdOutFilter(["TypeError: Cannot redefine property: prototype"]), "39 TypeError: Cannot redefine property:", "",      0    ),
    FailCollector("99_others", "99_others", "[99] others",                                                                              3 if platform.machine() == 'x86_64' else 26   ),
]

mjsunit_failCollectors_be = [
    FailCollector(StdErrFilter(["AOT::precompile_with_js failed"]),                 "01 precompile_with_js_failed", "",                 0    ),
    FailCollector(StdErrFilter(["MaglevGraphBuilder"]),                             "02 MaglevGraphBuilder", "",                        2  if platform.machine() == 'x86_64' else 0  ),
    FailCollector(StdErrFilter(["goto_label_->statement()"]),                       "03 goto_label_->statement()", "",                  0    ),
    FailCollector(StdErrFilter(["nameTable_[scope].count"]),                        "04 nameTable_[scope].count", "" ,                  0    ),
    FailCollector(StdErrFilter(["eval not fully support"]),                         "05 eval not fully support", "",                    21   ),
    FailCollector(StdOutFilter(["GenerateBytecode verifyModule fail"]),             "06 GenerateBytecode verifyModule fail", "",        0    ),
    FailCollector(StdErrFilter(["Check failed: IsSmi"]),                            "07 Check failed: IsSmi", "",                       0    ),
    FailCollector(StdOutFilter(["undefined:1: EvalError"]),                         "08 undefined:1: EvalError", "",                    17  ),
    FailCollector(StdOutFilter(["got a EvalError"]),                                "09 got a EvalError", "",                           0   ),
    FailCollector(StdErrFilter(["GenDebuggerStatement"]),                           "10 GenDebuggerStatement", "",                      0    ),
    FailCollector(StdErrFilter(["GenCallRuntime"]),                                 "11 GenCallRuntime:", "",                           3219  if platform.machine() == 'x86_64' else 3209 ),
    FailCollector(StdErrFilter(["GenWithStatement"]),                               "13 GenWithStatement:", "",                         67  ),
    FailCollector(StdErrFilter(["GenGetTemplateObject"]),                           "14 GenGetTemplateObject:", "",                     0    ),
    FailCollector(StdErrFilter(["BuildVariableLoad"]),                              "15 BuildVariableLoad:", "",                        38  if platform.machine() == 'x86_64' else 0 ),
    FailCollector(StdErrFilter(["Runtime_ResolvePossiblyDirectEval"]),              "17 Runtime_ResolvePossiblyDirectEval:", "",        42  ),
    FailCollector(StdErrFilter(["BuildVariableAssignment"]),                        "18 BuildVariableAssignment:", "",                  3   ),
    FailCollector(StdErrFilter(["PrepareAssignmentLhs"]),                           "18 PrepareAssignmentLhs:", "",                     0    ),
    FailCollector(StdErrFilter(["index < size()"]),                                 "19 index < size():", "",                           0    ),
    FailCollector(StdOutFilter(["HermesBuiltin_throwTypeError"]),                   "20 HermesBuiltin_throwTypeError", "",              0    ),
    FailCollector(StdOutFilter(["slot0"]),                                          "21 block scope: slot0", "",                        0    ),
    FailCollector(StdErrFilter(["!(is_async && is_generator)"]),                    "22 !(is_async && is_generator):", "",              0    ),
    FailCollector(StdOutFilter(["TypeError: Cannot read properties of undefined"]), "23 Cannot read properties of undefined", "",       2    ),
    FailCollector(StdOutFilter(["is not defined"]),                                 "24 reference_error", "",                           17  ),
    FailCollector(StdOutFilter(["Test262:AsyncTestFailure"]),                       "25 Test262:AsyncTestFailure", "",                  0  ),
    FailCollector(StdOutFilter(["should have the same contents"]),                  "26 should have the same contents", "",             0    ),
    FailCollector(StdOutFilter(["Test262Error to be thrown"]),                      "27 Test262Error to be thrown", "",                 0   ),
    FailCollector(StdOutFilter(['Expected SameValue']),                             '28 Expected SameValue', "",                        0   ),
    FailCollector(StdOutFilter(['Expected a TypeError to be thrown']),              '29 Expected a TypeError to be thrown', "",         0   ),
    FailCollector(StdOutFilter(['Expected a SyntaxError']),                         '30 Expected a SyntaxError', "",                    0    ),
    FailCollector(StdOutFilter(['Expected a ReferenceError']),                      '31 Expected a ReferenceError', "",                 0    ),
    FailCollector(StdOutFilter(['descriptor value should be']),                     '32 descriptor value should be', "",                0    ),
    FailCollector(StdOutFilter(["Test262Error: "]),                                 "33 Test262Error:", "",                             0   ),
    FailCollector(StdErrFilter(["syntax check should be performed"]),               "34 regx syntax check should be performed", "",     0    ),
    FailCollector(StdErrFilter(["TIMEOUT"]),                                        "35 TIMEOUT", "",                                   5    ),
    FailCollector(StdOutFilter(["native code"]),                                    "36 native code", "",                               0    ),
    FailCollector(StdErrFilter(["Received signal 11 SEGV_MAPERR"]),                 "37 Received signal 11 SEGV_MAPERR", "",            2    ),
    FailCollector(StdOutFilter(["TypeError: undefined is not a function"]),         "38 TypeError: undefined is not a function", "",    0    ),
    FailCollector(StdOutFilter(["TypeError: Cannot redefine property: prototype"]), "39 TypeError: Cannot redefine property:", "",      0    ),
    FailCollector("99_others", "99_others", "[99] others",                                                                              126 if platform.machine() == 'x86_64' else 166  ),
]

intl_failCollectors_be = [
    FailCollector(StdErrFilter(["GenCallRuntime"]),                                 "01 GenCallRuntime:", "",                           1  ),
    FailCollector(StdOutFilter(["is not defined"]),                                 "02 reference_error", "",                           1  ),
    FailCollector(StdOutFilter(["eval() not support"]),                             "03 intl/assert.js:189 not support", "",            3  ),
    FailCollector(StdOutFilter(["is not an instance of <RangeError>"]),             "04 thrown exception type mismatch", "",            1    ),
    FailCollector("99_others", "99_others", "[99] others",                                                                              0   ),
]

message_failCollectors_be = [
    FailCollector(StdErrFilter(["AOT::precompile_with_js failed"]),                 "01 precompile_with_js_failed", "",                 0    ),
    FailCollector(StdErrFilter(["MaglevGraphBuilder"]),                             "02 MaglevGraphBuilder", "",                        0    ),
    FailCollector(StdErrFilter(["goto_label_->statement()"]),                       "03 goto_label_->statement()", "",                  0    ),
    FailCollector(StdErrFilter(["nameTable_[scope].count"]),                        "04 nameTable_[scope].count", "" ,                  0    ),
    FailCollector(StdErrFilter(["eval not fully support"]),                         "05 eval not fully support", "",                    0   ),
    FailCollector(StdOutFilter(["GenerateBytecode verifyModule fail"]),             "06 GenerateBytecode verifyModule fail", "",        0    ),
    FailCollector(StdErrFilter(["Check failed: IsSmi"]),                            "07 Check failed: IsSmi", "",                       0    ),
    FailCollector(StdOutFilter(["undefined:1: EvalError"]),                         "08 undefined:1: EvalError", "",                    0  ),
    FailCollector(StdOutFilter(["got a EvalError"]),                                "09 got a EvalError", "",                           0   ),
    FailCollector(StdErrFilter(["GenDebuggerStatement"]),                           "10 GenDebuggerStatement", "",                      0    ),
    FailCollector(StdErrFilter(["GenCallRuntime"]),                                 "11 GenCallRuntime:", "",                           5  ),
    FailCollector(StdErrFilter(["GenWithStatement"]),                               "13 GenWithStatement:", "",                         1  ),
    FailCollector(StdErrFilter(["GenGetTemplateObject"]),                           "14 GenGetTemplateObject:", "",                     0    ),
    FailCollector(StdErrFilter(["BuildVariableLoad"]),                              "15 BuildVariableLoad:", "",                        0    ),
    FailCollector(StdErrFilter(["Runtime_ResolvePossiblyDirectEval"]),              "17 Runtime_ResolvePossiblyDirectEval:", "",        0  ),
    FailCollector(StdErrFilter(["BuildVariableAssignment"]),                        "18 BuildVariableAssignment:", "",                  0   ),
    FailCollector(StdErrFilter(["PrepareAssignmentLhs"]),                           "18 PrepareAssignmentLhs:", "",                     0    ),
    FailCollector(StdErrFilter(["index < size()"]),                                 "19 index < size():", "",                           0    ),
    FailCollector(StdOutFilter(["HermesBuiltin_throwTypeError"]),                   "20 HermesBuiltin_throwTypeError", "",              0    ),
    FailCollector(StdOutFilter(["slot0"]),                                          "21 block scope: slot0", "",                        0    ),
    FailCollector(StdErrFilter(["!(is_async && is_generator)"]),                    "22 !(is_async && is_generator):", "",              0 ),
    FailCollector(StdOutFilter(["TypeError: Cannot read properties of undefined"]), "23 Cannot read properties of undefined", "",       6    ),
    FailCollector(StdOutFilter(["is not defined"]),                                 "24 reference_error", "",                           8  ),
    FailCollector(StdOutFilter(["Test262:AsyncTestFailure"]),                       "25 Test262:AsyncTestFailure", "",                  0  ),
    FailCollector(StdOutFilter(["should have the same contents"]),                  "26 should have the same contents", "",             0    ),
    FailCollector(StdOutFilter(["Test262Error to be thrown"]),                      "27 Test262Error to be thrown", "",                 0   ),
    FailCollector(StdOutFilter(['Expected SameValue']),                             '28 Expected SameValue', "",                        0   ),
    FailCollector(StdOutFilter(['Expected a TypeError to be thrown']),              '29 Expected a TypeError to be thrown', "",         0   ),
    FailCollector(StdOutFilter(['Expected a SyntaxError']),                         '30 Expected a SyntaxError', "",                    0    ),
    FailCollector(StdOutFilter(['Expected a ReferenceError']),                      '31 Expected a ReferenceError', "",                 0    ),
    FailCollector(StdOutFilter(['descriptor value should be']),                     '32 descriptor value should be', "",                0    ),
    FailCollector(StdOutFilter(["Test262Error: "]),                                 "33 Test262Error:", "",                             0  ),
    FailCollector(StdErrFilter(["syntax check should be performed"]),               "34 regx syntax check should be performed", "",     0    ),
    FailCollector(StdErrFilter(["TIMEOUT"]),                                        "35 TIMEOUT", "",                                   0    ),
    FailCollector(StdOutFilter(["native code"]),                                    "36 native code", "",                               0    ),
    FailCollector(StdErrFilter(["Received signal 11 SEGV_MAPERR"]),                 "37 Received signal 11 SEGV_MAPERR", "",            0    ),
    FailCollector(StdOutFilter(["TypeError: undefined is not a function"]),         "38 TypeError: undefined is not a function", "",    8    ),
    FailCollector(StdOutFilter(["TypeError: Cannot redefine property: prototype"]), "39 TypeError: Cannot redefine property:", "",      0    ),
    FailCollector("99_others", "99_others", "[99] others",                                                                              266   ),
]

webkit_failCollectors_be = [
    FailCollector(StdErrFilter(["AOT::precompile_with_js failed"]),                 "01 precompile_with_js_failed", "",                 0    ),
    FailCollector(StdErrFilter(["MaglevGraphBuilder"]),                             "02 MaglevGraphBuilder", "",                        0    ),
    FailCollector(StdErrFilter(["goto_label_->statement()"]),                       "03 goto_label_->statement()", "",                  0    ),
    FailCollector(StdErrFilter(["nameTable_[scope].count"]),                        "04 nameTable_[scope].count", "" ,                  0    ),
    FailCollector(StdErrFilter(["eval not fully support"]),                         "05 eval not fully support", "",                    3   ),
    FailCollector(StdOutFilter(["GenerateBytecode verifyModule fail"]),             "06 GenerateBytecode verifyModule fail", "",        0    ),
    FailCollector(StdErrFilter(["Check failed: IsSmi"]),                            "07 Check failed: IsSmi", "",                       0    ),
    FailCollector(StdOutFilter(["undefined:1: EvalError"]),                         "08 undefined:1: EvalError", "",                    2  ),
    FailCollector(StdOutFilter(["got a EvalError"]),                                "09 got a EvalError", "",                           0   ),
    FailCollector(StdErrFilter(["GenDebuggerStatement"]),                           "10 GenDebuggerStatement", "",                      2    ),
    FailCollector(StdErrFilter(["GenCallRuntime"]),                                 "11 GenCallRuntime:", "",                           0  ),
    FailCollector(StdErrFilter(["GenWithStatement"]),                               "13 GenWithStatement:", "",                         10  ),
    FailCollector(StdErrFilter(["GenGetTemplateObject"]),                           "14 GenGetTemplateObject:", "",                     0    ),
    FailCollector(StdErrFilter(["BuildVariableLoad"]),                              "15 BuildVariableLoad:", "",                        1   if platform.machine() == 'x86_64' else 0  ),
    FailCollector(StdErrFilter(["Runtime_ResolvePossiblyDirectEval"]),              "17 Runtime_ResolvePossiblyDirectEval:", "",        33  ),
    FailCollector(StdErrFilter(["BuildVariableAssignment"]),                        "18 BuildVariableAssignment:", "",                  0   ),
    FailCollector(StdErrFilter(["PrepareAssignmentLhs"]),                           "18 PrepareAssignmentLhs:", "",                     0    ),
    FailCollector(StdErrFilter(["index < size()"]),                                 "19 index < size():", "",                           0    ),
    FailCollector(StdOutFilter(["HermesBuiltin_throwTypeError"]),                   "20 HermesBuiltin_throwTypeError", "",              0    ),
    FailCollector(StdOutFilter(["slot0"]),                                          "21 block scope: slot0", "",                        0    ),
    FailCollector(StdErrFilter(["!(is_async && is_generator)"]),                    "22 !(is_async && is_generator):", "",              0 ),
    FailCollector(StdOutFilter(["TypeError: Cannot read properties of undefined"]), "23 Cannot read properties of undefined", "",       0    ),
    FailCollector(StdOutFilter(["is not defined"]),                                 "24 reference_error", "",                           8  ),
    FailCollector(StdOutFilter(["Test262:AsyncTestFailure"]),                       "25 Test262:AsyncTestFailure", "",                  0  ),
    FailCollector(StdOutFilter(["should have the same contents"]),                  "26 should have the same contents", "",             0    ),
    FailCollector(StdOutFilter(["Test262Error to be thrown"]),                      "27 Test262Error to be thrown", "",                 0   ),
    FailCollector(StdOutFilter(['Expected SameValue']),                             '28 Expected SameValue', "",                        0   ),
    FailCollector(StdOutFilter(['Expected a TypeError to be thrown']),              '29 Expected a TypeError to be thrown', "",         0   ),
    FailCollector(StdOutFilter(['Expected a SyntaxError']),                         '30 Expected a SyntaxError', "",                    0    ),
    FailCollector(StdOutFilter(['Expected a ReferenceError']),                      '31 Expected a ReferenceError', "",                 0    ),
    FailCollector(StdOutFilter(['descriptor value should be']),                     '32 descriptor value should be', "",                0    ),
    FailCollector(StdOutFilter(["Test262Error: "]),                                 "33 Test262Error:", "",                             0   ),
    FailCollector(StdErrFilter(["syntax check should be performed"]),               "34 regx syntax check should be performed", "",     0    ),
    FailCollector(StdErrFilter(["TIMEOUT"]),                                        "35 TIMEOUT", "",                                   0    ),
    FailCollector(StdOutFilter(["native code"]),                                    "36 native code", "",                               0    ),
    FailCollector(StdErrFilter(["Received signal 11 SEGV_MAPERR"]),                 "37 Received signal 11 SEGV_MAPERR", "",            0    ),
    FailCollector(StdOutFilter(["TypeError: undefined is not a function"]),         "38 TypeError: undefined is not a function", "",    0    ),
    FailCollector(StdOutFilter(["TypeError: Cannot redefine property: prototype"]), "39 TypeError: Cannot redefine property:", "",      0    ),
    FailCollector("99_others", "99_others", "[99] others",                                                                              27  if platform.machine() == 'x86_64' else 28  ),
]

def read_json_file(file_path):
    try:
        with open(file_path, 'r') as f:
            data = json.load(f)
            return data
    except FileNotFoundError:
        print(f"Error: File not found: {file_path}")
        return None
    except json.JSONDecodeError as e:
        print(f"Error: Invalid JSON data in {file_path}: {e}")
        return None

def analysis(results, failCollectors, dump = False):
    print('>>>')
    for test in results:
        for fc in failCollectors:
            if fc.run(test):
                break

    # 输出所有失败用例到 .temp
    failed_type = ""
    expect_ir_fail = 0
    for fc in failCollectors:
        expect_ir_fail += fc.maximum
        if fc.tag == "02 MaglevGraphBuilder":
            if len(fc.failList) > fc.maximum:
                failed_type = fc.tag
        elif len(fc.failList) != fc.maximum :
            failed_type = fc.tag
        print(f"{fc.tag:<40}\t real_failed {len(fc.failList):<10} \t expected_max {fc.maximum:<10}")
        if len(fc.failList) > 0 and dump:
            with open(f".temp/{fc.tag}.json", "w") as f:
                json.dump(fc.failList, f, indent=4)
    print('<<<')

    print(f"real    : {len(results)}")
    print(f"expected: {expect_ir_fail}")

    if failed_type != "":
        print(f"{failed_type} failed")
        exit(-1)
    print("success\n")

def main():
    assert len(sys.argv) == 3
    try:
        shutil.rmtree(".temp")
    except FileNotFoundError:
        pass
    be_content = read_json_file(sys.argv[1])
    test_name = sys.argv[2]
    be_results = be_content["results"]

    os.mkdir(".temp")
    with open(f".temp/be_results.json", "w") as f:
        json.dump(be_results, f, indent=4)

    be_test_total = be_content["test_total"]
    print(f"be test_total: {be_test_total}, failed: {len(be_results)}, passed: {be_test_total - len(be_results)}")
    if test_name == "test262" :
        analysis(be_results, test262_failCollectors_be, True)
    elif test_name == "mjsunit" :
        analysis(be_results, mjsunit_failCollectors_be, True)
    elif test_name == "intl" :
        analysis(be_results, intl_failCollectors_be, False)
    elif test_name == "message" :
        analysis(be_results, message_failCollectors_be, True)
    elif test_name == "webkit" :
        analysis(be_results, webkit_failCollectors_be, True)
    else :
        print(test_name + " is not support!")

if __name__ == "__main__":
    main()
 